﻿namespace Sai.Core.Introspection
{
	using System;
	using System.Collections.Generic;

	/// <summary>
	/// Comparison based on full type name.
	/// </summary>
	public class TypeDeclarationNameComparer : IEqualityComparer<ITypeDeclaration>
	{
		public bool Equals(ITypeDeclaration x, ITypeDeclaration y)
		{
			if (object.ReferenceEquals(x, y))
			{
				return true;
			}

			if (object.ReferenceEquals(x, null) || object.ReferenceEquals(y, null))
			{
				return false;
			}

			return x.TypeName.CompareTo(y.TypeName) == 0;
		}

		public int GetHashCode(ITypeDeclaration obj)
		{
			return obj.TypeName.GetHashCode();
		}
	}
}
